/**
 * 2009-11-22 上午11:28:28 
 * esignature
 * com.smc.action.user
 * UserADAction
 */
package com.smc.action.user;

import com.smc.domain.model.Certification;
import com.smc.security.Authentication;
import com.smc.security.SecurityContextHolder;

/**
 * @author chenheng
 * @version 0.0.1 医生表现层控制操作类
 */
public class UserUSAction extends AbstractUserAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6018937618108332084L;
	
	private String keyalg ;
	/**
	 * sigalg算法跟keyalg算法相关；
	 * 假如私有钥匙是"DSA"类型,缺省签名算法是"SHA1withDSA"；
	 * 假如私有钥匙是"RSA"类型,缺省算法是"MD5withRSA"。
	 */
	private String sigalg ;
	private String keysize ;
	private String validity ;
	private String keypass ;
	private String cn ;
	private String ou ;
	private String o ;
	private String l ;
	private String st ;
	private String c ;
	
	public String getC() {
		return c;
	}
	public void setC(String c) {
		this.c = c;
	}
	public String getCn() {
		return cn;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	public String getKeyalg() {
		return keyalg;
	}
	public void setKeyalg(String keyalg) {
		this.keyalg = keyalg;
	}
	public String getKeypass() {
		return keypass;
	}
	public String getSigalg() {
		return sigalg;
	}
	public void setSigalg(String sigalg) {
		this.sigalg = sigalg;
	}
	public void setKeypass(String keypass) {
		this.keypass = keypass;
	}
	public String getKeysize() {
		return keysize;
	}
	public void setKeysize(String keysize) {
		this.keysize = keysize;
	}
	public String getL() {
		return l;
	}
	public void setL(String l) {
		this.l = l;
	}
	public String getO() {
		return o;
	}
	public void setO(String o) {
		this.o = o;
	}
	public String getOu() {
		return ou;
	}
	public void setOu(String ou) {
		this.ou = ou;
	}
	public String getSt() {
		return st;
	}
	public void setSt(String st) {
		this.st = st;
	}
	public String getValidity() {
		return validity;
	}
	public void setValidity(String validity) {
		this.validity = validity;
	}

	//////////////////////////////////////////////////
	public String applyCertificate() {
		sigalg = "DSA".equalsIgnoreCase(keyalg) ? "SHA1withDSA" : "MD5withRSA";
		Certification cert = new Certification();
		Authentication auth = SecurityContextHolder.getAuthentication(request.getSession()); 
		cert.setUserUuid(auth.getUUUID().toString());
		cert.setAlias(auth.getName());
		cert.setAuthorized(false);
		cert.setC(c);
		cert.setCn(cn);
		cert.setKeyalg(keyalg);
		cert.setKeypass(keypass);
		cert.setKeysize(keysize);
		cert.setL(l);
		cert.setO(o);
		cert.setOu(ou);
		cert.setSigalg(sigalg);
		cert.setSt(st);
		cert.setValidity(validity);
		certService.save_US_CE_SA_certification(cert);
		return SUCCESS ;
	}
	
}
